import { ReactNode } from "react";
import { Navigate } from "react-router-dom";

type Props = {
  children: ReactNode;
};

function AuthRouter(props: Props) {
  const token = localStorage.getItem("token");
  if (token) {
    return <>{props.children}</>;
  } else {
    return <Navigate to={"/login"} replace></Navigate>;
  }
}

export default AuthRouter;
